#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#define Maxsize 50
using namespace std;

typedef struct 
{
    int data[Maxsize];
    int length;
}Sqlist;

void CreateList(Sqlist *&L,int a[],int n)
{
    int i=0,k=0;
    L=(Sqlist *)malloc(sizeof(Sqlist));
    while (i<n)
    {
        L->data[k]=a[i];
        k++;i++;
    }
    L->length=k;
    printf("A list has been created.\n");
}

void DestroyList(Sqlist *&L)
{
    free(L);
}

bool ListEmpty(Sqlist *L)
{
    return(L->length==0);
}

int ListLength(Sqlist *L)
{
    return(L->length);
}    

void DispList(Sqlist *L)
{
    for (int i = 0; i < L->length; i++)
    {
        printf("%d",L->data[i]);
    }
    printf("\n");
}

bool GetElem(Sqlist *L,int i,int &e)
{
    if (i<1||i>L->length)
    {
        return false;
    }
    e=L->data[i-1];
    return true;
}

int LocateElem(Sqlist *L,int e)
{
    int i=0;
    while (i<L->length&&L->data[i]!=e)
    {
        i++;
    }
    if(i>=L->length)
    {
        return 0;
    }
    else
    {
        return i+1;
    }
}

void delnodel(Sqlist *&L,int e)
{
    int k=0,i;
    for ( i = 0; i < L->length; i++)
    {
        if(L->data[i]!=e)
        {
            L->data[k]=L->data[i];
            k++;
        }
    }
    L->length=k;
}

int main()
{
    Sqlist *L;
    int a[]={1,2,3,4,5};
    int n=4;
    int e=3;
    bool IsParameterTrue;
    CreateList(L,a,n);
    DispList(L);
    IsParameterTrue=GetElem(L,2,e);
    printf("%d",e);
    return 0;
}